package flc.ast.activity;

import static flc.ast.utils.ModuleCategory.BASIC_INFO;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.google.android.flexbox.FlexDirection;
import com.google.android.flexbox.FlexboxLayoutManager;
import com.google.android.flexbox.JustifyContent;
import com.google.gson.reflect.TypeToken;

import java.util.ArrayList;
import java.util.List;

import flc.ast.BaseAc;
import flc.ast.HomeActivity;
import flc.ast.R;
import flc.ast.adapter.ExpAdapter;
import flc.ast.adapter.SkillAdapter;
import flc.ast.bean.ExpBean;
import flc.ast.bean.ResumeBean;
import flc.ast.databinding.ActivityAllResumeBinding;
import flc.ast.dialog.DeleteDialog;
import flc.ast.utils.CalculatorUtil;
import flc.ast.utils.ModuleCategory;
import flc.ast.utils.ResumeDataUtils;
import stark.common.basic.event.EventStatProxy;

public class AllResumeActivity extends BaseAc<ActivityAllResumeBinding> {

    private List<ResumeBean> listShow = new ArrayList<>();
    private int selPos;

    @Override
    protected int onCreate() {
        return R.layout.activity_all_resume;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(this, mDataBinding.event1Container);
        EventStatProxy.getInstance().statEvent5(this, mDataBinding.event5Container);

        mDataBinding.ivAllResumeBack.setOnClickListener(v -> onBackPressed());

        mDataBinding.ivLast.setOnClickListener(this);
        mDataBinding.ivNext.setOnClickListener(this);
        mDataBinding.tvDelete.setOnClickListener(this);
    }

    @Override
    protected void onClickCallback(View v) {
        switch (v.getId()) {
            case R.id.ivLast://上一个
                if (selPos == 0) return;
                selPos--;
                setResumeData();
                break;
            case R.id.ivNext://下一个
                if (selPos == listShow.size() - 1) return;
                selPos++;
                setResumeData();
                break;
            case R.id.tvDelete://删除
                showDeleteDialog();
                break;
        }
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onResume() {
        super.onResume();
        getData();
    }

    private void getData() {
        listShow.clear();
        List<ResumeBean> listSp = ResumeDataUtils.getResumeList();
        if (listSp != null && listSp.size() > 0) {
            listShow.addAll(listSp);
            setResumeData();
        }
    }

    private void setResumeData() {
        mDataBinding.tvNum.setText((selPos + 1) + "/" + listShow.size());
        ResumeBean currentBean = listShow.get(selPos);
        List<ResumeBean.Module> listModule = currentBean.getResumeData();
        mDataBinding.llContent.removeAllViews();
        for (int i = 0; i < listModule.size(); i++) {
            int finalI = i;
            ResumeBean.Module module = listModule.get(i);
            if (!module.isShow()) continue;
            View itemView = null;
            if (module.getName().equals(BASIC_INFO.getCode())) {
                if (module.getData() != null) {
                    ResumeBean.BaseInfoData baseInfoData = GsonUtils.fromJson(GsonUtils.toJson(module.getData()), ResumeBean.BaseInfoData.class);
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.layout_basic_info, mDataBinding.llContent, false);
                    ImageView ivPhoto = itemView.findViewById(R.id.ivPhoto);
                    ImageView ivSex = itemView.findViewById(R.id.ivSex);
                    TextView tvName = itemView.findViewById(R.id.tvName);
                    TextView tvSex = itemView.findViewById(R.id.tvSex);
                    TextView tvBirthday = itemView.findViewById(R.id.tvBirthday);
                    TextView tvWorkTime = itemView.findViewById(R.id.tvWorkTime);
                    TextView tvPhone = itemView.findViewById(R.id.tvPhone);
                    TextView tvEmail = itemView.findViewById(R.id.tvEmail);
                    if (baseInfoData.getAvatar() != null) {
                        Glide.with(mContext).load(baseInfoData.getAvatar()).into(ivPhoto);
                    } else {
                        ivPhoto.setImageResource(R.drawable.atjzp);
                    }
                    tvName.setText(baseInfoData.getName());
                    if (baseInfoData.getSex().equals("男")) {
                        ivSex.setImageResource(R.drawable.axbn);
                    } else {
                        ivSex.setImageResource(R.drawable.axbnv);
                    }
                    tvSex.setText(baseInfoData.getSex());
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                        tvBirthday.setText(CalculatorUtil.calculateAge(baseInfoData.getDateOfBirth()) + getString(R.string.age_text));
                    }
                    tvPhone.setText(baseInfoData.getPhone());
                    tvEmail.setText(baseInfoData.getEmail());
                } else {
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.item_module, mDataBinding.llContent, false);
                    TextView tvName = itemView.findViewById(R.id.tvModuleItemName);
                    tvName.setText(module.getAlias());
                }
            } else if (module.getName().equals(ModuleCategory.JOB_INTENTION.getCode())) {
                if (module.getData() != null) {
                    ResumeBean.JobData jobData = GsonUtils.fromJson(module.getData().toString(), ResumeBean.JobData.class);
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.layout_other, mDataBinding.llContent, false);
                    TextView tvTitle = itemView.findViewById(R.id.tvTitle);
                    TextView tvContent = itemView.findViewById(R.id.tvContent);
                    tvTitle.setText(module.getAlias());
                    tvContent.setText(jobData.getTargetJob() + "   " + jobData.getTargetCity() + "   " + jobData.getEntryTime() + "   " + jobData.getTargetSalary());
                } else {
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.item_module, mDataBinding.llContent, false);
                    TextView tvName = itemView.findViewById(R.id.tvModuleItemName);
                    tvName.setText(module.getAlias());
                }
            } else if (module.getName().equals(ModuleCategory.EDUCATION_EXP.getCode())) {
                if (module.getData() != null) {
                    ResumeBean.EducationInfoData educationInfoData = GsonUtils.fromJson(module.getData().toString(), ResumeBean.EducationInfoData.class);
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.layout_exp, mDataBinding.llContent, false);
                    TextView tvTitle = itemView.findViewById(R.id.tvTitle);
                    ImageView ivAdd = itemView.findViewById(R.id.ivAdd);
                    RecyclerView recyclerView = itemView.findViewById(R.id.rvExpList);
                    tvTitle.setText(module.getAlias());
                    recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
                    ExpAdapter expAdapter = new ExpAdapter();
                    recyclerView.setAdapter(expAdapter);
                    List<ExpBean> list = new ArrayList<>();
                    educationInfoData.setEducationExperienceList(GsonUtils.fromJson(educationInfoData.getEducationExperienceList().toString(), new TypeToken<List<ResumeBean.EducationExperience>>() {
                    }.getType()));
                    for (ResumeBean.EducationExperience educationExperience : educationInfoData.getEducationExperienceList()) {
                        educationExperience.setDetailList(GsonUtils.fromJson(educationExperience.getDetailList().toString(), new TypeToken<List<ResumeBean.DetailItem>>() {
                        }.getType()));
                        String title = educationExperience.getSchoolName() + " | " + educationExperience.getQualification() + " | " +
                                educationExperience.getMajor() + " | " + educationExperience.getStartTime() + " ～ " +
                                educationExperience.getEndTime();
                        String detail = "";
                        for (ResumeBean.DetailItem detailItem : educationExperience.getDetailList()) {
                            detail += detailItem.getText() + "\n";
                        }
                        list.add(new ExpBean(title, detail));
                    }
                    expAdapter.setList(list);
                    expAdapter.setOnItemClickListener(new OnItemClickListener() {
                        @Override
                        public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                            EducationExpActivity.position = selPos;
                            EducationExpActivity.modulePos = finalI;
                            EducationExpActivity.dataPos = position;
                            startActivity(EducationExpActivity.class);
                        }
                    });
                } else {
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.item_module, mDataBinding.llContent, false);
                    TextView tvName = itemView.findViewById(R.id.tvModuleItemName);
                    tvName.setText(module.getAlias());
                }
            } else if (module.getName().equals(ModuleCategory.WORK_EXP.getCode())) {
                if (module.getData() != null) {
                    ResumeBean.WorkExperienceData workExperienceData = GsonUtils.fromJson(module.getData().toString(), ResumeBean.WorkExperienceData.class);
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.layout_exp, mDataBinding.llContent, false);
                    TextView tvTitle = itemView.findViewById(R.id.tvTitle);
                    ImageView ivAdd = itemView.findViewById(R.id.ivAdd);
                    RecyclerView recyclerView = itemView.findViewById(R.id.rvExpList);
                    tvTitle.setText(module.getAlias());
                    recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
                    ExpAdapter expAdapter = new ExpAdapter();
                    recyclerView.setAdapter(expAdapter);
                    List<ExpBean> list = new ArrayList<>();
                    workExperienceData.setWorkExperienceList(GsonUtils.fromJson(workExperienceData.getWorkExperienceList().toString(), new TypeToken<List<ResumeBean.WorkExperience>>() {
                    }.getType()));
                    for (ResumeBean.WorkExperience workExperience : workExperienceData.getWorkExperienceList()) {
                        String title = workExperience.getCompanyName() + " | " + workExperience.getJob() + " | " +
                                workExperience.getStartTime() + " ~ " + workExperience.getEndTime();
                        String detail = "";
                        workExperience.setDetailList(GsonUtils.fromJson(workExperience.getDetailList().toString(), new TypeToken<List<ResumeBean.DetailItem>>() {
                        }.getType()));
                        for (ResumeBean.DetailItem detailItem : workExperience.getDetailList()) {
                            detail += detailItem.getText() + "\n";
                        }
                        list.add(new ExpBean(title, detail));
                    }
                    expAdapter.setList(list);
                    expAdapter.setOnItemClickListener(new OnItemClickListener() {
                        @Override
                        public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                            WorkExpActivity.position = selPos;
                            WorkExpActivity.modulePos = finalI;
                            WorkExpActivity.dataPos = position;
                            startActivity(WorkExpActivity.class);
                        }
                    });
                } else {
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.item_module, mDataBinding.llContent, false);
                    TextView tvName = itemView.findViewById(R.id.tvModuleItemName);
                    tvName.setText(module.getAlias());
                }
            } else if (module.getName().equals(ModuleCategory.CAMPUS_ACTIVITY.getCode())) {
                if (module.getData() != null) {
                    ResumeBean.SchoolExperienceData schoolExperienceData = GsonUtils.fromJson(module.getData().toString(), ResumeBean.SchoolExperienceData.class);
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.layout_exp, mDataBinding.llContent, false);
                    TextView tvTitle = itemView.findViewById(R.id.tvTitle);
                    ImageView ivAdd = itemView.findViewById(R.id.ivAdd);
                    RecyclerView recyclerView = itemView.findViewById(R.id.rvExpList);
                    tvTitle.setText(module.getAlias());
                    recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
                    ExpAdapter expAdapter = new ExpAdapter();
                    recyclerView.setAdapter(expAdapter);
                    List<ExpBean> list = new ArrayList<>();
                    schoolExperienceData.setSchoolExperienceList(GsonUtils.fromJson(schoolExperienceData.getSchoolExperienceList().toString(), new TypeToken<List<ResumeBean.SchoolExperience>>() {
                    }.getType()));
                    for (ResumeBean.SchoolExperience schoolExperience : schoolExperienceData.getSchoolExperienceList()) {
                        String title = schoolExperience.getProjectName() + " | " + schoolExperience.getRoleName() + " | " +
                                schoolExperience.getStartTime() + " ~ " + schoolExperience.getEndTime();
                        String detail = "";
                        schoolExperience.setDetailList(GsonUtils.fromJson(schoolExperience.getDetailList().toString(), new TypeToken<List<ResumeBean.DetailItem>>() {
                        }.getType()));
                        for (ResumeBean.DetailItem detailItem : schoolExperience.getDetailList()) {
                            detail += detailItem.getText() + "\n";
                        }
                        list.add(new ExpBean(title, detail));
                    }
                    expAdapter.setList(list);
                    expAdapter.setOnItemClickListener(new OnItemClickListener() {
                        @Override
                        public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                            CampusActActivity.position = selPos;
                            CampusActActivity.modulePos = finalI;
                            CampusActActivity.dataPos = position;
                            startActivity(CampusActActivity.class);
                        }
                    });
                } else {
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.item_module, mDataBinding.llContent, false);
                    TextView tvName = itemView.findViewById(R.id.tvModuleItemName);
                    tvName.setText(module.getAlias());
                }
            } else if (module.getName().equals(ModuleCategory.INTERNSHIP_EXP.getCode())) {
                if (module.getData() != null) {
                    ResumeBean.InternShipExperienceData internShipExperienceData = GsonUtils.fromJson(module.getData().toString(), ResumeBean.InternShipExperienceData.class);
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.layout_exp, mDataBinding.llContent, false);
                    TextView tvTitle = itemView.findViewById(R.id.tvTitle);
                    ImageView ivAdd = itemView.findViewById(R.id.ivAdd);
                    RecyclerView recyclerView = itemView.findViewById(R.id.rvExpList);
                    tvTitle.setText(module.getAlias());
                    recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
                    ExpAdapter expAdapter = new ExpAdapter();
                    recyclerView.setAdapter(expAdapter);
                    List<ExpBean> list = new ArrayList<>();
                    internShipExperienceData.setInternShipExperienceList(GsonUtils.fromJson(internShipExperienceData.getInternShipExperienceList().toString(), new TypeToken<List<ResumeBean.InternShipExperience>>() {
                    }.getType()));
                    for (ResumeBean.InternShipExperience internShipExperience : internShipExperienceData.getInternShipExperienceList()) {
                        String title = internShipExperience.getCompanyName() + " | " + internShipExperience.getJob() + " | " +
                                internShipExperience.getStartTime() + " ~ " + internShipExperience.getEndTime();
                        String detail = "";
                        internShipExperience.setDetailList(GsonUtils.fromJson(internShipExperience.getDetailList().toString(), new TypeToken<List<ResumeBean.DetailItem>>() {
                        }.getType()));
                        for (ResumeBean.DetailItem detailItem : internShipExperience.getDetailList()) {
                            detail += detailItem.getText() + "\n";
                        }
                        list.add(new ExpBean(title, detail));
                    }
                    expAdapter.setList(list);
                    expAdapter.setOnItemClickListener(new OnItemClickListener() {
                        @Override
                        public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                            InternshipExpActivity.position = selPos;
                            InternshipExpActivity.modulePos = finalI;
                            InternshipExpActivity.dataPos = position;
                            startActivity(InternshipExpActivity.class);
                        }
                    });
                } else {
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.item_module, mDataBinding.llContent, false);
                    TextView tvName = itemView.findViewById(R.id.tvModuleItemName);
                    tvName.setText(module.getAlias());
                }
            } else if (module.getName().equals(ModuleCategory.PROJECT_EXP.getCode())) {
                if (module.getData() != null) {
                    ResumeBean.ProjectExperienceData projectExperienceData = GsonUtils.fromJson(module.getData().toString(), ResumeBean.ProjectExperienceData.class);
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.layout_exp, mDataBinding.llContent, false);
                    TextView tvTitle = itemView.findViewById(R.id.tvTitle);
                    ImageView ivAdd = itemView.findViewById(R.id.ivAdd);
                    RecyclerView recyclerView = itemView.findViewById(R.id.rvExpList);
                    tvTitle.setText(module.getAlias());
                    recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
                    ExpAdapter expAdapter = new ExpAdapter();
                    recyclerView.setAdapter(expAdapter);
                    List<ExpBean> list = new ArrayList<>();
                    projectExperienceData.setProjectExperienceList(GsonUtils.fromJson(projectExperienceData.getProjectExperienceList().toString(), new TypeToken<List<ResumeBean.ProjectExperience>>() {
                    }.getType()));
                    for (ResumeBean.ProjectExperience projectExperience : projectExperienceData.getProjectExperienceList()) {
                        String title = projectExperience.getProjectName() + " | " + projectExperience.getRoleName() + " | " +
                                projectExperience.getStartTime() + " ~ " + projectExperience.getEndTime();
                        String detail = "";
                        projectExperience.setDetailList(GsonUtils.fromJson(projectExperience.getDetailList().toString(), new TypeToken<List<ResumeBean.DetailItem>>() {
                        }.getType()));
                        for (ResumeBean.DetailItem detailItem : projectExperience.getDetailList()) {
                            detail += detailItem.getText() + "\n";
                        }
                        list.add(new ExpBean(title, detail));
                    }
                    expAdapter.setList(list);
                    expAdapter.setOnItemClickListener(new OnItemClickListener() {
                        @Override
                        public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                            ProjectExpActivity.position = selPos;
                            ProjectExpActivity.modulePos = finalI;
                            ProjectExpActivity.dataPos = position;
                            startActivity(ProjectExpActivity.class);
                        }
                    });
                } else {
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.item_module, mDataBinding.llContent, false);
                    TextView tvName = itemView.findViewById(R.id.tvModuleItemName);
                    tvName.setText(module.getAlias());
                }
            } else if (module.getName().equals(ModuleCategory.PROFESSIONAL_SKILL.getCode())) {
                if (module.getData() != null) {
                    ResumeBean.SkillData skillData = GsonUtils.fromJson(module.getData().toString(), ResumeBean.SkillData.class);
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.layout_skill, mDataBinding.llContent, false);
                    TextView tvTitle = itemView.findViewById(R.id.tvTitle);
                    RecyclerView recyclerView = itemView.findViewById(R.id.rvSkillList);
                    tvTitle.setText(module.getAlias());
                    FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(mContext);
                    layoutManager.setFlexDirection(FlexDirection.ROW);
                    layoutManager.setJustifyContent(JustifyContent.FLEX_START);
                    recyclerView.setLayoutManager(layoutManager);
                    SkillAdapter skillAdapter = new SkillAdapter();
                    skillAdapter.setEdit(false);
                    recyclerView.setAdapter(skillAdapter);
                    skillData.setDetailList(GsonUtils.fromJson(skillData.getDetailList().toString(), new TypeToken<List<ResumeBean.DetailItem>>() {
                    }.getType()));
                    skillAdapter.setList(skillData.getDetailList());
                } else {
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.item_module, mDataBinding.llContent, false);
                    TextView tvName = itemView.findViewById(R.id.tvModuleItemName);
                    tvName.setText(module.getAlias());
                }
            } else if (module.getName().equals(ModuleCategory.HONORARY_CERTIFICATE.getCode())) {
                if (module.getData() != null) {
                    ResumeBean.CertificateData certificateData = GsonUtils.fromJson(module.getData().toString(), ResumeBean.CertificateData.class);
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.layout_other, mDataBinding.llContent, false);
                    TextView tvTitle = itemView.findViewById(R.id.tvTitle);
                    TextView tvContent = itemView.findViewById(R.id.tvContent);
                    tvTitle.setText(module.getAlias());
                    String detail = "";
                    certificateData.setDetailList(GsonUtils.fromJson(certificateData.getDetailList().toString(), new TypeToken<List<ResumeBean.DetailItem>>() {
                    }.getType()));
                    for (ResumeBean.DetailItem detailItem : certificateData.getDetailList()) {
                        detail += detailItem.getText() + "\n";
                    }
                    certificateData.setCertificateList(GsonUtils.fromJson(certificateData.getCertificateList().toString(), new TypeToken<List<ResumeBean.CertificateItem>>() {
                    }.getType()));
                    for (ResumeBean.CertificateItem certificateItem : certificateData.getCertificateList()) {
                        detail += certificateItem.getText() + "\n";
                    }
                    tvContent.setText(detail);
                } else {
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.item_module, mDataBinding.llContent, false);
                    TextView tvName = itemView.findViewById(R.id.tvModuleItemName);
                    tvName.setText(module.getAlias());
                }
            } else if (module.getName().equals(ModuleCategory.HOBBIES_INTERESTS.getCode())) {
                if (module.getData() != null) {
                    ResumeBean.HobbyData hobbyData = GsonUtils.fromJson(module.getData().toString(), ResumeBean.HobbyData.class);
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.layout_other, mDataBinding.llContent, false);
                    TextView tvTitle = itemView.findViewById(R.id.tvTitle);
                    TextView tvContent = itemView.findViewById(R.id.tvContent);
                    tvTitle.setText(module.getAlias());
                    String detail = "";
                    hobbyData.setDetailList(GsonUtils.fromJson(hobbyData.getDetailList().toString(), new TypeToken<List<ResumeBean.DetailItem>>() {
                    }.getType()));
                    for (ResumeBean.DetailItem detailItem : hobbyData.getDetailList()) {
                        detail += detailItem.getText() + "\n";
                    }
                    tvContent.setText(detail);
                } else {
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.item_module, mDataBinding.llContent, false);
                    TextView tvName = itemView.findViewById(R.id.tvModuleItemName);
                    tvName.setText(module.getAlias());
                }
            } else if (module.getName().equals(ModuleCategory.SELF_EVALUATION.getCode())) {
                if (module.getData() != null) {
                    ResumeBean.SelfEvaluationData selfEvaluationData = GsonUtils.fromJson(module.getData().toString(), ResumeBean.SelfEvaluationData.class);
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.layout_other, mDataBinding.llContent, false);
                    TextView tvTitle = itemView.findViewById(R.id.tvTitle);
                    TextView tvContent = itemView.findViewById(R.id.tvContent);
                    tvTitle.setText(module.getAlias());
                    String detail = "";
                    selfEvaluationData.setDetailList(GsonUtils.fromJson(selfEvaluationData.getDetailList().toString(), new TypeToken<List<ResumeBean.DetailItem>>() {
                    }.getType()));
                    for (ResumeBean.DetailItem detailItem : selfEvaluationData.getDetailList()) {
                        detail += detailItem.getText() + "\n";
                    }
                    tvContent.setText(detail);
                } else {
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.item_module, mDataBinding.llContent, false);
                    TextView tvName = itemView.findViewById(R.id.tvModuleItemName);
                    tvName.setText(module.getAlias());
                }
            } else if (module.getName().equals(ModuleCategory.CUSTOM_TITLE.getCode())) {
                if (module.getData() != null) {
                    ResumeBean.CustomModuleData customModuleData = GsonUtils.fromJson(module.getData().toString(), ResumeBean.CustomModuleData.class);
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.layout_other, mDataBinding.llContent, false);
                    TextView tvTitle = itemView.findViewById(R.id.tvTitle);
                    TextView tvContent = itemView.findViewById(R.id.tvContent);
                    tvTitle.setText(module.getAlias());
                    String detail = "";
                    customModuleData.setDetailList(GsonUtils.fromJson(customModuleData.getDetailList().toString(), new TypeToken<List<ResumeBean.DetailItem>>() {
                    }.getType()));
                    for (ResumeBean.DetailItem detailItem : customModuleData.getDetailList()) {
                        detail += detailItem.getText() + "\n";
                    }
                    tvContent.setText(detail);
                } else {
                    itemView = LayoutInflater.from(mContext).inflate(R.layout.item_module, mDataBinding.llContent, false);
                    TextView tvName = itemView.findViewById(R.id.tvModuleItemName);
                    tvName.setText(module.getAlias());
                }
            }
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    switch (ModuleCategory.fromCode(module.getName())) {
                        case BASIC_INFO://基本信息
                            BasicInfoActivity.position = selPos;
                            BasicInfoActivity.modulePos = finalI;
                            startActivity(BasicInfoActivity.class);
                            break;
                        case JOB_INTENTION://求职意向
                            JobIntentionActivity.position = selPos;
                            JobIntentionActivity.modulePos = finalI;
                            startActivity(JobIntentionActivity.class);
                            break;
                        case EDUCATION_EXP://教育经历
                            EducationExpActivity.position = selPos;
                            EducationExpActivity.modulePos = finalI;
                            EducationExpActivity.dataPos = -1;
                            startActivity(EducationExpActivity.class);
                            break;
                        case WORK_EXP://工作经历
                            WorkExpActivity.position = selPos;
                            WorkExpActivity.modulePos = finalI;
                            WorkExpActivity.dataPos = -1;
                            startActivity(WorkExpActivity.class);
                            break;
                        case PROFESSIONAL_SKILL://专业技能
                            ProfessionalSkillActivity.position = selPos;
                            ProfessionalSkillActivity.modulePos = finalI;
                            startActivity(ProfessionalSkillActivity.class);
                            break;
                        case CAMPUS_ACTIVITY://校园活动
                            CampusActActivity.position = selPos;
                            CampusActActivity.modulePos = finalI;
                            CampusActActivity.dataPos = -1;
                            startActivity(CampusActActivity.class);
                            break;
                        case INTERNSHIP_EXP://实习经历
                            InternshipExpActivity.position = selPos;
                            InternshipExpActivity.modulePos = finalI;
                            InternshipExpActivity.dataPos = -1;
                            startActivity(InternshipExpActivity.class);
                            break;
                        case PROJECT_EXP://项目经验
                            ProjectExpActivity.position = selPos;
                            ProjectExpActivity.modulePos = finalI;
                            ProjectExpActivity.dataPos = -1;
                            startActivity(ProjectExpActivity.class);
                            break;
                        case HONORARY_CERTIFICATE://荣誉证书
                            CertificateActivity.position = selPos;
                            CertificateActivity.modulePos = finalI;
                            startActivity(CertificateActivity.class);
                            break;
                        default:
                            OtherInfoActivity.moduleCategory = module.getName();
                            OtherInfoActivity.position = selPos;
                            OtherInfoActivity.modulePos = finalI;
                            startActivity(OtherInfoActivity.class);
                            break;
                    }
                }
            });
            mDataBinding.llContent.addView(itemView);
        }
    }

    private void showDeleteDialog() {
        DeleteDialog deleteDialog = new DeleteDialog(mContext);
        deleteDialog.setListener(new DeleteDialog.Ilistener() {
            @Override
            public void clickConfirm() {
                listShow.remove(selPos);
                ResumeDataUtils.saveResumeList(listShow);
                ToastUtils.showShort(getString(R.string.delete_suc));
                if (selPos == 0) {
                    startActivity(HomeActivity.class);
                } else {
                    selPos--;
                    setResumeData();
                }
            }
        });
        deleteDialog.show();
    }

}